import requests

url = "https://fanyi.baidu.com/basetrans"

data_dict = {
    #query输入你想要的单词
    "query": "测试",
    "from": "zh",
    "to": "en",
    "token": "c60c6021dda15820a72a077d95c8a68e",
    "sign": "706553.926920",
}

headers_dict = {
    "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1 Edg/97.0.4692.71",
    'Cookie':
        'BAIDUID=4A86A91BD242A4E1E03B60ED322EB401:FG=1;' 'Hm_lvt_afd111fa62852d1f37001d1f980b6800=1642784020; '
        'Hm_lpvt_afd111fa62852d1f37001d1f980b6800=1642784319;'
        '__yjs_duid=1_71ec58fcd8bc1239e2f71415df97bf7d1642784321594;'
        'Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1642768690,1642768731,1642769300;'
        'Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1642784319;'
        'ab_sr=1.0.1_ZWNkMjY1YzA0ZTY4YjM0NGEyOWU3ZWFhNTQwMjFhOTZmZGMwZTc5MTg3NjM4YzJlMmVmYWJlMzIwOTRlNDExM2I3YzQyNTQ5MDMxYjZlMTIzOTA4OWE0N2YxOWYzMmE0;'
        'BAIDUID_BFESS=4A86A91BD242A4E1E03B60ED322EB401:FG=1'

}

response = requests.post(url, data=data_dict, headers=headers_dict)
print(response.json()['en_ph']['ph_en'])
